package com.itext.utils;

import com.itextpdf.text.Document;
import com.itextpdf.text.Element;
import com.itextpdf.text.Phrase;
import com.itextpdf.text.pdf.ColumnText;
import com.itextpdf.text.pdf.PdfContentByte;
import com.itextpdf.text.pdf.PdfPageEventHelper;
import com.itextpdf.text.pdf.PdfWriter;

/**
 * 页眉工具类
 * @author mbc
 *
 */
public class Header extends PdfPageEventHelper {
	
	private Phrase p;
	
	public Header(){}
	
	public Header(Phrase p){
		this.p = p;
	}
	public void onEndPage(PdfWriter writer, Document document) {
		PdfContentByte cb = writer.getDirectContent();
		ColumnText.showTextAligned(cb, Element.ALIGN_CENTER, this.p,
				(document.right() - document.left()) / 2 + document.leftMargin(), document.top() + 10, 0);
	}

}
